﻿/*include:js\declare*/
//默认值输入框	<input defaultinput="" readonly="readonly" id="XXX" type="text" />
(function(){
var DefaultInput=function()
	{
	this.GetArgument(arguments[0],{Id:null,Event:null,Value:null});
	this.DefaultValue=this.Value;
	this.Start(this.Event||{IsGetOnly:1});
	};
(fastCSharp.Functions.DefaultInput=DefaultInput).Inherit(fastCSharp.BaseFunction,{
Start:function(Event)
	{
	if(!Event.IsGetOnly)
		{
		var Element=fastCSharp.$Id(this.Id),Input=Element.Element();
		if(Input!=this.Element)
			{
			this.Element=Input;
			Element.AddEvent('blur',fastCSharp.ThisFunction(this,this.OnBlur)).Set('readOnly',false);
			if(this.DefaultValue==null)
				{
				this.Value=Element.Value();
				this.LastValue='';
				}
			else	this.LastValue=this.Value=this.DefaultValue;
			}
		if(Element.Value()==this.Value&&this.LastValue=='')	Element.Value('');
		Element.Focus();
		this.IsFocus=this.LastValue=1;
		}
	},
OnBlur:function()
	{
	if((this.LastValue=this.$Value(this.Id).Trim())=='')	this.$Id(this.Id).Value(this.Value);
	this.IsFocus=0;
	},
GetValue:function()
	{
	var Element=fastCSharp.$Id(this.Id),Input=Element.Element();
	if(Input==this.Element)
		{
		var Value=Element.Value();
		return Value==this.Value&&this.LastValue==''?'':Value;
		}
	return '';
	}
		});
new fastCSharp.Declare('DefaultInput','focus','Src');
})();